﻿@model AvaliacaoOnline.Data.Cliente

@{
    ViewBag.Title = "Avaliação Online - Cadastro de cliente";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
<script type="text/javascript">
    upload = function () {
        $("#upload").dialog({
            modal: true,
            title: 'Carregar arquivos',
            buttons: {
                "Upload": function () {
                    $("#ajaxUploadForm").submit();
                },
                "Cancelar": function () {
                    $(this).dialog('close');
                }
            }
        });
    }
</script>
@if (!String.IsNullOrWhiteSpace(ViewData["Message"] as string))
{
<script type="text/javascript">
    $(function () {
        $.showMessage({ message: '@(Html.Raw(ViewData["Message"] as string))', beforeClose: function () { location.href = '@Url.Content("~/cliente/list/")' } });
    });
</script>
}
}


<h3>Cliente</h3>

<div id="text1" class="span-24">
@using (Html.BeginForm("Save", "Cliente", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <input type="hidden" name="Id" id="Id" value="@Model.Id" />
    <input type="hidden" name="LogoImagem" id="LogoImagem" value="@Model.LogoImagem" />
    <div class="span-3">Nome</div>
    <div class="span-18 last form">
        <input type="text" name="Nome" value="@Model.Nome" style="width:600px;" maxlength="200" />
    </div>
    <div class="clear"></div>
    <div class="span-3">Url cliente</div>
    <div class="span-18 last form">
        <input type="text" name="Url" value="@Model.Url" style="width:600px;" maxlength="200" />
    </div>
    <div class="clear"></div>
    if (Model.Id != 0)
    {
        <div class="span-3">Logo</div>
        <div class="span-15 last form">
            <a href="@ViewData["ImagemURL"]" id="arquivoTipo1" target="_blank">@Model.LogoImagem</a>
            <a href="javascript:upload();" style="float:right;">@(@Model.LogoImagem == "" ? "Inserir" : "Alterar") imagem</a>
        </div>
    }
    <br />
    <br />
    <div class="span-18 last" style="text-align:right;">
        <input type="submit" name="Salvar" value="Salvar alterações" id="Salvar"/>
    </div>
}
</div>

<div id="upload" style="display:none; width:200px; height:120px;">
    <form id="ajaxUploadForm" action="@Url.Action("Upload", "Cliente")" method="post" enctype="multipart/form-data">
        <input type="hidden" name="IdCliente" id="IdCliente" value="@Model.Id" />
        <div>Selecione o arquivo:</div>
        <input type="file" name="file" />
    </form>
</div>

